﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using ExtendPropertyLib;

namespace ExORMDesginer.Models
{

    public interface ILoger
    {
        /// <summary>
        /// 写入日志
        /// </summary>
        /// <param name="msg">日志信息</param>
        void Write(string msg);
        /// <summary>
        /// 清除日志
        /// </summary>
        void Clear();

    }

    /// <summary>
    /// 文本日志类
    /// </summary>
    [Export(typeof(ILoger))]
    public class TextLoger : BusinessInfoBase<TextLoger> , ILoger
    {
        public TextLoger()
        {
            Message = "";
        }


        public static ExtendProperty MessageProperty = RegisterProperty(v => v.Message);
        /// <summary>
        /// 日志消息
        /// </summary>
        public string Message { set { SetValue(MessageProperty, value); } get { return (string )GetValue(MessageProperty); } }

        public void Write(string msg)
        {
            Message += msg + Environment.NewLine;
        }

        public void Clear()
        {
            Message = "";
        }


    }
}
